<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<!--{include file='comm/header.tpl'}-->
    <title>角色权限分配</title>
    <!--{include file='comm/comm_pic.tpl'}-->
	<style>
		li {
			width:164px;
			height:24px;
			line-height:24px;
			text-align:left;
			display:block;
			float:left;
		}
	</style>
</head>
<body>
	<div style="width:100%">
		
		<div class="items clearfix">
			
			<h2 style="" class="tal">
				正在操作：【<!--{$role_array.roleName}-->】权限分配
			</h2>
			
			<div class="items2">

                <div class="select-box">

                    <!--{foreach from=$permission_group_array item=group name=foo}-->
                        <!--{if $smarty.foreach.foo.first}-->
                            <div class="selected" id="bana_<!--{$group.permissionGroupID}-->" style="width: 90px;">
                                <!--{$group.permissionGroupName}-->
                            </div>
                        <!--{else}-->
                            <div id="bana_<!--{$group.permissionGroupID}-->" style="width: 90px;">
                                <!--{$group.permissionGroupName}-->
                            </div>
                        <!--{/if}-->
                    <!--{/foreach}-->

                </div>

                <div>

                    <form id="permissionForm" onsubmit="return false;">

                        <!--{foreach from=$permission_group_array item=group name=foo}-->
                            <div id="div_<!--{$group.permissionGroupID}-->" style="<!--{if $smarty.foreach.foo.first}-->display:block;<!--{else}-->display:none;<!--{/if}-->">
                                <ul style="width:656px;padding-left:50px;" id="ul_<!--{$group.permissionGroupID}-->">
                                    <!--{foreach from=$group.list item=permission}-->
                                        <li>
                                            <input type="checkbox" name="checkPer" value="<!--{$permission.permissionID}-->" <!--{if $permission.checked == 1}--> checked="checked" <!--{/if}-->>
                                            <!--{$permission.permissionName}-->
                                        </li>
                                    <!--{/foreach}-->
                                </ul>
                                <div style="clear:both;"></div>
                                <div style="padding-left:50px;padding-top:10px;">
                                    <input type="checkbox" id="allCheck_<!--{$group.permissionGroupID}-->" onclick="role.allCheck('<!--{$group.permissionGroupID}-->');">&nbsp;全选
                                </div>
                            </div>
                        <!--{/foreach}-->
                        <input type="hidden" value="<!--{$role_array.roleID}-->" name="roleID" />

                    </form>

                </div>

			</div>
			
		</div>
		
		<div class="bottom_fixbox">
	        <div class="rectbox tac">
	            <input type="button" class="btn" onclick="role.check();" value="保存" />&nbsp;&nbsp;&nbsp;
	            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
	        </div>
	    </div>

	</div>
<script type="text/javascript">

    $(window).ready(function() {

        $("div[id^=bana_]").click(function() {

            var id = $(this).attr("id").replace("bana_", "");
            $("div[id^=bana_]").removeClass("selected").eq($(this).index()).addClass("selected");
            $("div[id^=div]").hide().eq($(this).index()).show();

        });

    });

    var role = {

        dt: "",

        check: function() {

            this.dt = E.getFormValues("permissionForm");

            if (this.dt.checkPer.length == 0) {
                E.alert("请选择权限");
            } else {
                E.confirm("您确认要修改该角色权限吗？", "role.execute");
            }

        },

        execute: function() {

            E.loadding.open("正在保存角色权限信息，请稍候...");
            E.ajax_post({
                url: "/invokingAjax-backend/user/roleList.ajax?operFlg=4",
                data: this.dt,
                call: "role.result"
            });

        },

        result: function( o ) {

            E.loadding.close();
            if (o.code == 200) {
                E.alert("角色权限保存成功", 2, "E.closeWindows");
            } else {
                E.alert(o.message);
            }

        },

        //全选或全不选
        allCheck: function(permissionGroupID){
            var allCheck = document.getElementById('allCheck_'+permissionGroupID);
            var checkbox = $('#ul_'+permissionGroupID).find('input:checkbox');
            if (allCheck.checked == true){
                for(var i=0;i<checkbox.length;i++)
                    checkbox[i].checked = true;
            }else {
                for(var i=0;i<checkbox.length;i++)
                    checkbox[i].checked = false;
            }
        },

    };

</script>

</body>
</html>